<div aria-hidden="false" aria-labelledby="myModalLabel" role="dialog" tabindex="-1" id="uploadModal" class="modal hide fade" >
  <div class="modal-dialog">
    <div class="modal-header">
      <button id="closebtnupload" aria-hidden="true" data-dismiss="modal" class="close" type="button">&times;</button>
      <button  id="minimizebtn" aria-hidden="true" class="close" type="button">-</button>
      <h3 id="myModalLabel">Upload to AllFiles</h3>
    </div>
    <div class="modal-body">
    <input type="hidden" name="filepath" value="${folderPath}">
		<form id="upload" action=//s3-ap-southeast-1.amazonaws.com/${bucketS3} method="POST"
			enctype="multipart/form-data" class="direct-upload">
				 <div id="note"><a href="">index</a> </div>
				 
				 <input type="hidden" name="key"	value="${folderPath}<%= '${filename}' %>">
				 <input	type="hidden" name="AWSAccessKeyId" value="${accessKeyId }"> 
				 <input	type="hidden" name="acl" value="${aclPermission}">
				 <input type="hidden" name="success_action_status" value="201">	
				 <input type="hidden" name="policy" value="${base64Policy}">
				 <input	type="hidden" name="signature" value="${signature}">
				 <div id="drop">
						Drop Here
						<input id="browserfile" type="file" name="file" multiple="multiple" />
						<input id="browserfolder" type="file" webkitdirectory/>
					</div>
		
					<ul>
						<!-- The file uploads will be shown here -->
					</ul>
		</form>
   </div>
    <div class="modal-footer">
      <div class="leftbtn"> <a id="uploadfile" class="btn btn-primary refontbtn "><span class="iconfa-plus-sign"></span> File</a> <a id="uploadfolder"  class="btn btn-primary refontbtn"><span class="iconfa-plus-sign"></span> Folder</a> </div>
      <div class="rightbtn"> <a href=""  data-dismiss="modal" class="btn">Cancel</a> <a href="" class="btn btn-success">Begin Upload</a> </div>
    </div>
  </div>
</div>





<%--

<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<asset:javascript src="lib/jquery.fileupload.js" />

--%>

	<asset:javascript src="home/js/lib/jquery.knob.js" />
	<asset:javascript src="home/js/lib/jquery.ui.widget.js" />
	<asset:javascript src="home/js/lib/jquery.iframe-transport.js" />
	<asset:javascript src="home/js/lib/jquery.fileupload.js" />
	<asset:javascript src="home/js/lib/script.js" /><%--

<script>
		$(document).ready( function() {
			var filepath;
		    $('.direct-upload').each( function() {
		    	
				var form = $(this);
				
			
		        form.fileupload({
		        	
		            url: encodeURI(form.attr('action').toString()),
		            type: 'POST',
		            datatype: 'xml',
		           
		            add: function (event, data) {

		                // Message on unLoad.
		                window.onbeforeunload = function() {
		                    return 'You have unsaved changes.';
		                };

		                // Submit
		                data.submit();
		            },
		            progress: function(e, data){
		                // This is what makes everything really cool, thanks to that callback
		                // you can now update the progress bar based on the upload progress.
		                var percent = Math.round((data.loaded / data.total) * 100);
		                $('.bar').css('width', percent + '%');
		            },
		            fail: function(e, data) {
		                // Remove 'unsaved changes' message.
		                window.onbeforeunload = null;
		                $('.bar').css('width', '100%').addClass('red');
		            },
		            done: function (event, data) {
		        		//window.onbeforeunload = null;
		        		filepath = ${folderPath}+"/"+data.originalFiles[0].name;
		        		 $('#upload_original_name').val(data.originalFiles[0].name);
                         $('#upload_custom_name').val(data.originalFiles[0].name);
                         
		                // Fill the name field with the file's name.
		               // alert(''+filepath);
                         $.ajax({
                        	 type: 'POST',
     						dataType : "text",
     						url : "/Folder/SaveFilePath/",
     						data : {Filepath : $('input[name="filepath"]').val()+data.originalFiles[0].name },
     						success : function(data) {
     						},
     						error : function() {
     						}
     					});
		            },
		        });
		    });
		    
		});
	</script>

--%><script>
	function myfuntion(filename) {
		return $('input[name="filepath"]').val+data.originalFiles[0].name;
	}
</script>